package com.meta;

import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;

public class AnnotationDrivenFilter extends SimpleBeanPropertyFilter {

	private int version;

	public AnnotationDrivenFilter(int version) {
		this.version = version;
	}

	@Override
	protected boolean include(BeanPropertyWriter writer) {
		 Version version =  writer.getAnnotation(Version.class);
		 if( version == null || version.minVersion() ==0)
				return true;
		 
		 return version.minVersion() <= this.version;
	}

	public int getVersion() {
		return version;
	}

}
